<script type="text/javascript">
    $(document).ready(function(){
        $("#manga_table").dataTable();
    });
</script>

<div id="manga_list">

    <h2>List of manga</h2>
    <?php
    if ($all_manga->num_rows() > 0) {

        $tmpl = array(
            'table_open' => '<table id="manga_table" cellpadding="0" cellspacing="0" border="0" class="display">',
            'row_start'           => '<tr class="gradeA">',
            );

        $this->table->set_template($tmpl);

        $this->table->set_heading('ID', 'Title', 'Total Page', 'Edit', 'Delete');

        foreach ($all_manga->result() as $manga) {
            $id = $manga->manga_id;
            $title = $manga->title;
            $total_pages = $manga->total_pages;
            $edit = anchor($controller_url . 'edit_manga/' . $id, "Edit");
            $delete = anchor($controller_url . 'delete_manga/' . $id, 'Delete');

            $this->table->add_row($id, $title, $total_pages, $edit, $delete);
        }

        echo $this->table->generate();
    } else {
        echo "<p>There is no manga currently.</p>";
    }
    ?>
</div>

<div id="upload_manga">

    <h2>Upload new manga</h2>

    <?php
    echo form_open($controller_url . 'add_new_manga');

    echo form_label('Manga title: ', 'manga_title');

    echo form_input('manga_title');

    echo form_submit('add', 'Add');

    echo form_close();
    ?>

    <div id="errors_box">
        <?php echo validation_errors(); ?>
    </div>

</div>